package com.example.spingbootvue.exception;

import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

@ControllerAdvice
public class GlobalException {


    @ExceptionHandler(ServiceException.class)
    @ResponseBody
    public String serviceException(ServiceException e){
        String msg = e.getMessage();
        String code = e.getCode();
        return code + "\n" + msg;
    }
}
